//
//  DMMyTeamVC.m
//  DistributionMall
//
//  Created by JHnoplan on 2018/10/17.
//  Copyright © 2018年 JHnoplan. All rights reserved.
//

#import "DMMyTeamVC.h"
#import "FDSlideBar.h"
#import "DMMyTeamCell.h"
#import "DMMyTeamDetailVC.h"

@interface DMMyTeamVC ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UIView *headView;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UILabel *totalLb;
@property (nonatomic, strong) FDSlideBar *sliderBar;


@end

@implementation DMMyTeamVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self startInit];
}

-(void)startInit {
    
    self.navigationItem.title = @"我的团队";
    self.view.backgroundColor = DMWhiteColor;
    
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    //注册cell
    [_collectionView registerNib:[UINib nibWithNibName:@"DMMyTeamCell" bundle:nil] forCellWithReuseIdentifier:@"DMMyTeamCell"];

    //头部选择View
    [self makeSlideBar];
}

#pragma mark - collectionView
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 50;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake((ScreenWidth-40)/4, 117);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 5, 0, 5);
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"DMMyTeamCell";
    DMMyTeamCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];

    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    DMMyTeamDetailVC *vc = [DMMyTeamDetailVC new];
    [self.navigationController pushViewController:vc animated:YES];
}

//头部选择View
-(void)makeSlideBar {
    _sliderBar = [[FDSlideBar alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
    _sliderBar.itemsTitle = @[@"一级团队", @"二级团队"];
    _sliderBar.backgroundColor = [UIColor clearColor];
    _sliderBar.itemColor = DMFontColor;
    _sliderBar.itemSelectedColor = DMMainColor;
    _sliderBar.sliderColor = DMMainColor;
    [_sliderBar selectSlideBarItemAtIndex:0];
    [_sliderBar slideBarItemSelectedCallback:^(NSUInteger idx) {
        //选择,刷新tableView
        //        _index = idx;
        //
    }];
    [_headView addSubview:_sliderBar];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 44, ScreenWidth, 1)];
    line.backgroundColor = RGBCOLOR(237, 237, 237);
    [_headView addSubview:line];
}

@end
